#!/usr/bin/perl

use strict;
use warnings;
use CGI;
use File::Slurp;

print "Content-type: text/html\n\n";
print '<script type="text/javascript" src="jscolor.js"></script>';
print '<script type="text/javascript" src="large-color-selector.js"></script>';

my @css = read_file('style.css');
my @hex;

foreach my $line (@css) {
	if($line =~ /: #([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3});/) {
		my $hex = $1;
		push(@hex, $hex);
	}
}

my %seen = ();
@hex = grep { ! $seen{$_}++ } @hex;

print "<h2>Colors founds in style.css</h2>";

foreach my $color (@hex) {
	print "<input class=\"color\" value=\"$color\">";
}

print "<hr>";

foreach my $color (@hex) {
	print "<input class=\"large-color\" value=\"$color\">";
}

